package com.carreirati.evaluation;

import java.util.List;

import com.carreirati.evaluation.domain.VwGetAverageResultsByQuestions;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.roo.addon.web.mvc.controller.json.RooWebJson;
import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/vwgetaverageresultsbyquestionses")
@Controller
@RooWebScaffold(path = "vwgetaverageresultsbyquestionses", formBackingObject = VwGetAverageResultsByQuestions.class)
@RooWebJson(jsonObject = VwGetAverageResultsByQuestions.class)
public class VwGetAverageResultsByQuestionsController {
	
	 @RequestMapping(value = "/find{appraisalId}", headers = "Accept=application/json")
	    @ResponseBody
	    public ResponseEntity<java.lang.String> findJson(@PathVariable("appraisalId") long appraisalId, @RequestParam("questionId") long questionId) {
		 
		 	HttpHeaders headers = new HttpHeaders();
	        headers.add("Content-Type", "application/json; charset=utf-8");
	        List<VwGetAverageResultsByQuestions> result = VwGetAverageResultsByQuestions.findAllVwGetAverageResultsByQuestions(appraisalId, questionId);
	        return new ResponseEntity<String>(VwGetAverageResultsByQuestions.toJsonArray(result), headers, HttpStatus.OK);
	    }
	 
	 
	 @RequestMapping(value = "/findbyappraisal{appraisalId}", headers = "Accept=application/json")
	    @ResponseBody
	    public ResponseEntity<java.lang.String> findByAppraisalJson(@PathVariable("appraisalId") long appraisalId, @RequestParam("knowledgeAreaId") long knowledgeAreaId) {
	        HttpHeaders headers = new HttpHeaders();
	        headers.add("Content-Type", "application/json; charset=utf-8");
	        List<VwGetAverageResultsByQuestions> result = VwGetAverageResultsByQuestions.findAllVwGetAverageResultsByAppraisal(appraisalId,knowledgeAreaId);
	        return new ResponseEntity<String>(VwGetAverageResultsByQuestions.toJsonArray(result), headers, HttpStatus.OK);
	    }
	 
	 @RequestMapping(value = "/findbyevaluated{appraisalId}", headers = "Accept=application/json")
	    @ResponseBody
	    public ResponseEntity<java.lang.String> findbyevaluatedJson(@PathVariable("appraisalId") long appraisalId, @RequestParam("knowledgeAreaId") long knowledgeAreaId) {
	        HttpHeaders headers = new HttpHeaders();
	        headers.add("Content-Type", "application/json; charset=utf-8");
	        List<VwGetAverageResultsByQuestions> result = VwGetAverageResultsByQuestions.findAllVwGetAverageResultsByEvaluated(appraisalId,knowledgeAreaId);
	        return new ResponseEntity<String>(VwGetAverageResultsByQuestions.toJsonArray(result), headers, HttpStatus.OK);
	    }
	 
}
